<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>new (TunecoreDirect::Response)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File lib/tunecore_direct/response.rb, line 16</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>( <span class="ruby-identifier">body</span> )
      <span class="ruby-ivar">@body</span> = <span class="ruby-identifier">body</span>
      <span class="ruby-ivar">@doc</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">body</span> )
      <span class="ruby-ivar">@type</span> = <span class="ruby-ivar">@doc</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">name</span>
      <span class="ruby-ivar">@status</span> = <span class="ruby-ivar">@doc</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-value str">&quot;/*/status&quot;</span>].<span class="ruby-identifier">text</span>
    
      <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@status</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;error&quot;</span>
        <span class="ruby-comment cmt">#collect the error messages and put them in an array of hashes</span>
        <span class="ruby-ivar">@errors</span> = <span class="ruby-ivar">@doc</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">elements</span>.<span class="ruby-identifier">collect</span>(<span class="ruby-value str">&quot;/*/error&quot;</span>){<span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> {<span class="ruby-identifier">:attribute</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-value str">&quot;attribute&quot;</span>].<span class="ruby-identifier">text</span>, <span class="ruby-identifier">:message</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-value str">&quot;message&quot;</span>].<span class="ruby-identifier">text</span>} }
      <span class="ruby-keyword kw">end</span>
    <span class="ruby-keyword kw">end</span></pre>
</body>
</html>